Some tips given out to ease learning.

Question 1

In the development and design of most modern operating systems, a modular kernel may be the best of the design techniques. 
Explain why this is so. [4m]
        
Uses object-oriented approach, with a relatively small core kernel and a set of modules which can be linked in dynamically. 
Each core component is separate
Each talks to the others over known interfaces
Each is loadable as needed within the kernel

Lect 2 Slide 39/40


Question 2

Operating systems (OS) are interrupt driven. How interrupts are handled by the OS? [2m]
        
When an interrupt occurs, the OS saves the current state of the CPU, identifies the type of interrupt via an interrupt vector table, 
and executes the corresponding Interrupt Service Routine (ISR) to handle the interrupt. 
After handling the interrupt, the OS restores the CPU state and resumes the interrupted process. 
This allows the system to respond efficiently to events like hardware signals or system calls.

GPT


Question 3

What are the differences between a trap and an interrupt? What is the use of each type? [4m]
        
Interrupts are hardware based. It responds to external events. It is handled by interrupt service.
Traps are software based. It handle program errors or system calls. It is handled by the OS



Question 4

Explain how does stack overflow happen in a process? [2m]
    
The stack and the heap start at opposite ends of the process's free space and grow towards each other. 
If they should ever meet, then either a stack overflow error will occur, or else a call to new or malloc will fail due to insufficient memory available.

Lect 3 Slide 5


Question 5

A child process has a PID 1000, this child process is created by a parent Process. 
What is a possible PID value for the parent Process? [1m]

Any PID as long as it is not 1000
    
GPT


Question 6

How does mixing IO Burst program with CPU burst program increase the CPU utilization? [1m]
    
Because: 
I/O-bound process – spends more time doing I/O than computations, many short CPU bursts
CPU-bound process – spends more time doing computations; few very long CPU bursts

Lect 3 Slide 15


Question 7

Below is the process table
i) Draw the Gantt charts illustrating the execution of these processes using 
Pre-emptive Shortest Job First (SJF) and Round Robin (quantum=3) scheduling. [4m]

ii) What is the value of average turn-around time for Pre-emptive Shortest Job First (SJF) and Round Robin (quantum=3) scheduling. [2m]
    


Question 1

Process needs computer resources to accomplish its task. 
Provides four examples of computer resources. [4m]
        
Here are four examples of computer resources that a process needs to accomplish its task:

    CPU (Central Processing Unit): 
    The CPU is the core hardware responsible for executing instructions and performing computations for processes. 
    It is essential for running the code of a process.

    Memory (RAM): 
    Memory is required by a process to store data, variables, and instructions while it is running. 
    It includes both the system’s primary memory (RAM) and possibly cache memory.

    Disk Space: 
    Processes often need storage to read from or write to files, such as program files, data files, or temporary files. 
    Disk space provides long-term storage for data beyond volatile memory (RAM).

    Input/Output Devices: 
    Processes may require access to I/O devices such as a keyboard, mouse, display screen, printer, or network interfaces to interact with users or other systems.

These resources are crucial for a process to perform its intended operations and complete tasks effectively.

GPT



Question 2

Explain why the duration of thread execution is smaller than process execution? [2m]
        
Thread is smaller than a process.
Uses fewer resources than process creation.

Lect 1 Slide 45


Question 3

An application program interface (API) is a set of routines, protocols, and tools for building software applications. 
Provide two reasons on why use APIs rather than system calls? [4m]
        
Portability: Any program using that API can compile and run, as long as the system/program supports the API.

Ease of Use compared to actual system call.
Lect 2 Slide 14


Question 4

Context Switch occurred when CPU switches from one process to another process.

i) Explain what the steps are involved during the context switch [0.5m]
It involves saving and restoring all of the registers and program counter(s), as well as the process control blocks.
    
ii) Explain why an efficient Operating System should minimize the occurrence of context switch [0.5m]
Context-switch time is overhead; the system does no useful work while switching

Lect 3 Slide 18


Question 5

A signal handler is used to process signals. Explain the steps that involved. [1m]
    
Signal is generated by particular event
Signal is delivered to a process
Signal is handled

Lect 3 Slide 46


Question 6

How does mix IO Burst program with CPU burst program increase the CPU utilization? [1m]

Because: 
I/O-bound process – spends more time doing I/O than computations, many short CPU bursts
CPU-bound process – spends more time doing computations; few very long CPU bursts

Lect 3 Slide 15


Question 7

i) Draw the Gantt charts illustrating the execution of these processes using 
Pre-emptive Shortest Job First (Pre-SJF), Non-Pre-emptive Shortest Job First (Non-Pre- SJF) and Round Robin (quantum=3) scheduling.[6m]

ii) What is the value of average turn-around time for Round Robin (quantum=3) scheduling. [1m]    



Question 1

In operating systems, certain instructions could be executed only when the Central Processing Unit (CPU) is in kernel mode. 
Explain why by providing the reason. [2m]
    
Certain instructions in an operating system can only be executed when the CPU is in kernel mode because of privilege levels and the need for system security and stability.

    Privilege Levels: 
    The CPU operates in two primary modes: user mode and kernel mode. 
    In user mode, programs (applications) have limited access to system resources to prevent them from directly interacting with hardware or modifying critical system settings. 
    This restriction helps ensure that applications cannot inadvertently or maliciously disrupt the operating system or other applications.

    Access to Critical System Resources: 
    In kernel mode, the operating system has full access to all system resources, including hardware and memory. 
    Certain sensitive instructions, such as those that involve interacting with hardware, managing memory directly, or altering system configurations, require this level of access to ensure that they can be performed securely and correctly.

    Protection Mechanism: 
    Allowing only kernel-mode code (operating system code) to execute certain privileged instructions helps protect the system from user-mode programs. 
    If user-mode programs were allowed to execute such instructions, they could potentially cause system crashes, corrupt data, or even compromise security by gaining unauthorized access to hardware or memory.

In summary, executing certain instructions only in kernel mode ensures that only trusted, 
privileged code (i.e., the operating system) can perform critical tasks, maintaining both the security and stability of the system.

GPT



Question 2

The operating system gives several services to utility programmers and users. 
List and explain the FOUR important services that are provided by an operating system. [4m]
    
• User Interface (UI):
    o Types include Command-Line Interface (CLI), Graphical User Interface (GUI), and Batch.
    o Examples: Windows uses a GUI with CLI options; MacOS includes both GUI and UNIX shell options.
• Program Execution:
    o Loads programs into memory and manages normal or error-induced termination.
• I/O Operations:
    o Handles file access or device communication needs.
• File-System Manipulation:
    o Manages file creation, deletion, search, permissions, and directory operations.
• Communication:
    o Supports data exchange between processes via shared memory or message passing.
• Error Detection:
    o Identifies and manages hardware or program errors to maintain stability.
• Resource Allocation:
    o Distributes resources among multiple processes/users.
• Protection and Security:
    o Ensures controlled access to resources and defends against unauthorized access.

Lect 2 Slide 5++


Question 3

The process state diagram describes different process states during its lifetime. Schedulers are special system software which handle process scheduling in various ways.
From the Figure 1, find out the suitable schedulers for bringing a process to different process states. [3m]

i) Scheduler A (New to Ready)
ii) Scheduler B (Running to Waiting)
iii) Scheduler C (Ready to Running)

i) Long term scheduler
ii) Medium term scheduler
iii) Short term scheduler



Question 4

Consider the following set of processes in Table 1 below. Assume that lower numbers represent higher priority.

i) Draw the Gantt chart illustrating the execution of these processes using, Pre-emptive Shortest Job First (Pre-emptive SJF) with showing the necessary steps. Calculate the average turnaround time and the average waiting time for this algorithm.
[3m + 0.5m + 0.5m] ii) Draw the Gantt chart illustrating the execution of these processes using, Pre-emptive priority scheduling with showing the necessary steps. Calculate the average turnaround time and the average waiting time for this algorithm. [3m + 0.5m + 0.5m] iii) Draw the Gantt chart illustrating the execution of these processes using, Round Robin (RR) (quantum = 3) scheduling with showing the necessary steps. [3m]

Question 1

One of the benefits of multithreaded system is "Resource sharing".
Provide five of the resources thats shared among the threads. [2.5m]
    
Heap memory
Global variables
Code
Data
Files
Lect 3 Slide 4



Question 2

Among the three general methods for passing parameters to the operating systems,
which method is the fastest? [0.5m]
        
Pass parameters in registers



Question 3

Computer application developers often do not have direct access to the system calls, 
but can access system calls through an application programming interface (API). 
Provide and explain two benefits of applying API than system calls. [2m]
        
Portability: Any program using that API can compile and run, as long as the system/program supports the API.

Ease of Use compared to actual system call.
Lect 2 Slide 14


Question 4

In Linux, the 'ls' command lists the contents of the current working directory. 
Assume that you are accessing a Linux shell on LXTerminal and your current prompt is at 'lubuntu@lubuntu:~$'. 
By referring to the two figures below, provide two ways using the 'ls' command (by providing the required parameters and/or arguments) 
to list the files and directories contained in the SYSTEM directory. [3m]
        
cd OPERATING, cd SYSTEM, ls
ls OPERATING/SYSTEM 
or
ls/home/lubuntu/OPERATING/SYSTEM


Question 5

Assume that you are accessing a Linux shell on LXTerminal and your current prompt is at 'lubuntu@lubuntu:~$'. 
Provide the command (together with any required parameters and/or arguments) 
that renames a file on the same directory with label "SORRY" to "NO_CURE". [2m]
        
mv SORRY NO_CURE


Question 6


i) NPSJF
ii) PSJF
iii) NPPS
iv) PPS
v) RR (q=2)

 [10m]

Question 1

Question 2

Question 3

Question 4

Question 1

Question 2

Question 3

Question 1

Question 2

Question 3

Question 1

Question 2

Question 3

Question 1

Question 2

Question 3


Answers may not be correct, anything contact me.